<template>
	<view class="listProduct">
		<Hearder :name="title"></Hearder>
		<view class="shop_list" v-if="list.length">
			<view class="every" v-for="(item,index) in list" :key="item.goods_id" @click="$u.throttle(ljsnap(item.goods_id,item.is_order,item.order_id), 1000)">
				<view class="topimg">
					<image :src="item.goods_image"></image>
					<view class="null" v-if="item.is_order==2">
						<image src="/static/images/null.png"></image>
					</view>
				</view>
				<view class="every_bot">
					<view class="title">{{item.goods_name}}</view>
					<view class="bot-con">
						<view class="price-con">￥{{item.goods_min_price}}</view>
						<view class="status" style="background: #FF513A;color: #fff;">立即抢购</view>
					</view>
				</view>
			</view>
		</view>
		<u-skeleton
			rows="4"
			:title="false"
			:loading="loading"
			:rowsHeight="['102rpx', '706rpx', '100rpx', '200rpx']"
			:rowsWidth="['100%', '100%', '100%', '100%']"
			animate
		></u-skeleton>
		<view class="nidata" v-if="list.length==0">
			<image src="../../static/images/noimg.png"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				page:1,
				list:[],
				last_page:1,
				specialarea_type:1,
				title:'',
				loading:true
			}
		},
		onLoad(options) {
			this.specialarea_type = options.specialarea_type
			this.title = options.title
			uni.setNavigationBarTitle({
			　　title: options.title
			})
			this.getinit()
		},
		onReachBottom(){
			if(this.list.length){
				this.page = this.page + 1
				if (this.page <= this.last_page) {
					this.getinit()
				}
			}
		},
		methods:{
			getinit(){
				this.request('/loot/getCategoryGoodsList',{
					specialarea_id:1,
					specialarea_type:this.specialarea_type,
					page:this.page
				}).then(res => {
					if(res.data.code==1){
						this.list = this.list.concat(res.data.data.list)
						this.last_page = res.data.data.total_page
					}
					this.loading = false;
				})
			},
			ljsnap(goods_id,is_order,order_id){
				if(is_order!=2){
					this.request('/order/toAddOrder',{
						order_id:order_id,
						specialarea_id:1,
						goods_id:goods_id,
						specialarea_type:this.specialarea_type
					}).then(res => {
						if(res.data.code==1){
							uni.redirectTo({
								url:'lootsubmit?id='+goods_id+'&order_id='+res.data.data
							})
						}else{
							this.$tip(res.data.msg)
						}
					})
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.listProduct{
		min-height: 100%;
		background: $uni-background-color;
		.shop_list{
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			padding: 0 4% 30rpx;
			.every{
				overflow: hidden;
				width: 335rpx;
				margin-top: 22rpx;
				border-radius: 10rpx;
				background: #fff;
				.topimg{
					position: relative;
					height: 335rpx;
					image{
						width: 100%;
						height: 100%;
					}
					.null{
						position: absolute;
						top: 0;
						width: 100%;
						height: 100%;
						background: rgba(0,0,0,.5);
						image{
							position: absolute;
							top: 50%;
							left: 50%;
							transform: translate(-50%,-50%);
							width: 177rpx;
							height: 151rpx;
						}
					}
				}
				.every_bot{
					padding: 0 20rpx;
					.title{
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp:2;
						/*! autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
						line-height: 36rpx;
						font-size: 28rpx;
						margin-top: 20rpx;
						height: 70rpx;
					}
					.bot-con{
						display: flex;
						justify-content: space-between;
						align-items: center;
						padding: 20rpx 0;
						.price-con{
							color: $uni-text-color;
							font-weight: 800;
							margin-left: -4rpx;
						}
						.status{
							width: 140rpx;
							height: 50rpx;
							background: #eee;
							font-size: 24rpx;
							border-radius: 50rpx;
							line-height: 50rpx;
							text-align: center;
						}
					}
				}
			}
		}
	}
</style>